class PodcastController < ApplicationController

  before_filter :load_podcast, :only => [ :show ]
  before_filter :load_podcasts, :only => [ :index ]
  before_filter :find_tagged, :only => [ :tagged ]
  
  layout "two_column"

  protected
  def load_podcasts
    @podcasts = Podcast.paginate(:page => params[:page], :order => 'created_at DESC')
  end

  def load_podcast
    @podcast = Podcast.find(params[:id])
  end

  def find_tagged
    @podcasts = Podcast.find_tagged_with(params[:tag])
  end

  public
  def index
    respond_to do |format|
      format.html
      format.rss {render :layout => false}
      format.xml  { render :xml => @podcasts }
    end
  end

  def show          
    respond_to do |format|
      format.html
      format.xml  { render :xml => @podcast }
    end
  end

  def tagged
    respond_to do |format|
      format.html
      format.rss {render :layout => false}
      format.xml  { render :xml => @podcasts }
    end
  end

end
